<template>
	<view>
		<!-- <view class="padding bg-white" @tap='del'>
			注销账号
		</view> -->
		<view class="padding solid bg-white" @tap='about'>
			关于我们
		</view>
		<view class="padding solid bg-white" @tap='report'>
			意见反馈
		</view>
		<view class="padding solid bg-white" @tap='contact'>
			联系我们
		</view>
		
		
		<view @tap="loginOut" class="text-red margin-top-xl padding bg-white text-center">
			退出登录
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				defaultLink:'/pages/user/contact',
				aboutLink:'',
			}
		},
		onLoad() {
			this.getLink()
		},
		methods: {
			getLink(){
				let _this = this
				this.baseRequest('api/parm/', 'GET', {parmName:'aboutLink'}, function(res, info) {
					_this.aboutLink = res&&res.length>0?res[0].value:_this.defaultLink
				})
			},
			contact(){
				uni.navigateTo({
					url: '/pages/user/contact'
				});
			},
			report(){
				uni.navigateTo({
					url: '/pages/index/report?id=-1'
				});
			},
			about(){
				if(this.aboutLink.startsWith('http')){
					window.open(this.aboutLink)
				}else{
					 this.contact()
				}
				 
			},
			navTo(e) {
				let page = e.currentTarget.dataset.page;
				uni.navigateTo({
					url: '/pages/login/' + page
				});
			},
			del() {
				let _this = this;
				uni.showModal({
					title: '提示',
					content: '将注销账号信息，不可恢复，请确认操作？',
					success: function(res) {
						if (res.confirm) {
							uni.showLoading({
								mask: true,
								title: '请稍候...'
							})
							let u = uni.getStorageSync('ONLINE_USER');
							let userID = u.userID;
							_this.baseRequest('resetUser', 'DELETE', {userID,isLock: 0}, function(res, info) {
								uni.hideLoading();
								uni.clearStorageSync();
								setTimeout(() => {
									uni.reLaunch({
										url: '/pages/login/login'
									})
								}, 100);
							});
						}
					},
				});
			},
			loginOut() {
				let _this = this;
				uni.showModal({
					title: '提示',
					content: '即将退出跳转至登录页面，请确认操作？',
					success: function(res) {
						if (res.confirm) {
							uni.showLoading({
								mask: true,
								title: '请稍候...'
							})
							_this.baseRequest('logout', 'GET', {}, function(res, info) {
								uni.hideLoading();
								uni.clearStorageSync();
								setTimeout(() => {
									uni.reLaunch({
										url: '/pages/login/login'
									})
								}, 100);
							});
						}
					},
				});
			}
		}
	}
</script>

<style>

</style>
